use core::{Package, VirtualManifest, EitherManifest, SourceId};
use core::{PackageIdSpec, Dependency, Profile, Profiles};
-use ops;
use util::{Config, Filesystem};
use util::errors::{CargoResult, CargoResultExt};
use util::paths;
+use util::toml::read_manifest;
/// The core abstraction in Cargo for working with a workspace of crates.
///
Entry::Occupied(e) => Ok(e.into_mut()),
Entry::Vacant(v) => {
let source_id = SourceId::for_path(key)?;
- let pair = ops::read_manifest(&manifest_path, &source_id,
- self.config)?;
- let (manifest, _nested_paths) = pair;
+ let (manifest, _nested_paths) =
+ read_manifest(&manifest_path, &source_id, self.config)?;
Ok(v.insert(match manifest {
EitherManifest::Real(manifest) => {
MaybePackage::Package(Package::new(manifest,
use std::path::{Path, PathBuf};
use core::{Package, SourceId, PackageId, EitherManifest};
-use util::{self, paths, Config};
+use util::{self, Config};
use util::errors::{CargoResult, CargoResultExt};
use util::important_paths::find_project_manifest_exact;
-use util::toml::Layout;
-
-pub fn read_manifest(path: &Path, source_id: &SourceId, config: &Config)
- -> CargoResult<(EitherManifest, Vec<PathBuf>)> {
- trace!("read_package; path={}; source-id={}", path.display(), source_id);
- let contents = paths::read(path)?;
-
- let layout = Layout::from_project_path(path.parent().unwrap());
- let root = layout.root.clone();
- util::toml::to_manifest(&contents, source_id, layout, config).chain_err(|| {
- format!("failed to parse manifest at `{}`",
- root.join("Cargo.toml").display())
- })
-}
+use util::toml::read_manifest;
pub fn read_package(path: &Path, source_id: &SourceId, config: &Config)
-> CargoResult<(Package, Vec<PathBuf>)> {
pub use self::cargo_clean::{clean, CleanOptions};
pub use self::cargo_compile::{compile, compile_with_exec, compile_ws, CompileOptions};
pub use self::cargo_compile::{CompileFilter, CompileMode, MessageFormat, Packages};
-pub use self::cargo_read_manifest::{read_manifest,read_package,read_packages};
+pub use self::cargo_read_manifest::{read_package, read_packages};
pub use self::cargo_rustc::{compile_targets, Compilation, Kind, Unit};
pub use self::cargo_rustc::{Context, is_bad_artifact_name};
pub use self::cargo_rustc::{BuildOutput, BuildConfig, TargetConfig};
use core::manifest::{LibKind, Profile, ManifestMetadata};
use ops::is_bad_artifact_name;
use sources::CRATES_IO;
+use util::paths;
use util::{self, ToUrl, Config};
use util::errors::{CargoError, CargoResult, CargoResultExt};
-/// Representation of the projects file layout.
-///
-/// This structure is used to hold references to all project files that are relevant to cargo.
-
-#[derive(Clone)]
-pub struct Layout {
- pub root: PathBuf,
+/// Implicit Cargo targets, defined by conventions.
+struct Layout {
+ root: PathBuf,
lib: Option<PathBuf>,
bins: Vec<PathBuf>,
examples: Vec<PathBuf>,
impl Layout {
/// Returns a new `Layout` for a given root path.
/// The `root_path` represents the directory that contains the `Cargo.toml` file.
- pub fn from_project_path(root_path: &Path) -> Layout {
+ fn from_project_path(root_path: &Path) -> Layout {
let mut lib = None;
let mut bins = vec![];
let mut examples = vec![];
/* else just don't add anything if the directory doesn't exist, etc. */
}
-pub fn to_manifest(contents: &str,
- source_id: &SourceId,
- layout: Layout,
- config: &Config)
- -> CargoResult<(EitherManifest, Vec<PathBuf>)> {
+pub fn read_manifest(path: &Path, source_id: &SourceId, config: &Config)
+ -> CargoResult<(EitherManifest, Vec<PathBuf>)> {
+ trace!("read_manifest; path={}; source-id={}", path.display(), source_id);
+ let contents = paths::read(path)?;
+
+ let layout = Layout::from_project_path(path.parent().unwrap());
+ let root = layout.root.clone();
+ to_manifest(&contents, source_id, layout, config).chain_err(|| {
+ format!("failed to parse manifest at `{}`",
+ root.join("Cargo.toml").display())
+ })
+}
+
+fn to_manifest(contents: &str,
+ source_id: &SourceId,
+ layout: Layout,
+ config: &Config)
+ -> CargoResult<(EitherManifest, Vec<PathBuf>)> {
let manifest = layout.root.join("Cargo.toml");
let manifest = match util::without_prefix(&manifest, config.cwd()) {
Some(path) => path.to_path_buf(),